<?php

use think\facade\Route;
use think\facade\Request;


//接口版本控制
$version = Request::header('version', 'v1');
$method = Request::method();
$method = strtolower($method);
//兼容快捷路由和按请求方式访问
$pathArr = explode('/', Request::pathinfo());
$function = '';
$rule = '';
if (count($pathArr) > 1) {
    $function = '<function>';
    $rule = '/';
}
$route = $version . '.<controller>/' . $method . $function;
$rule = '<controller>' . $rule . $function;
//无需验证控制器,验证单独添加auth中间件
Route::group(function () use ($rule, $route) {
    Route::any($rule, $route);
})->middleware(['throttle']);


